package Demo1;

import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 34255
 * Date: 2024-07-28
 * Time: 16:31
 */

class Student implements Comparable<Student>{
    @Override
    public int compareTo(Student o) {
        return 0;
    }
}
public class Test {
    public static void main(String[] args) {
        Set<Student> set = new TreeSet<>();
        set.add(new Student());
    }
    public static void main6(String[] args) {
        Set<Integer> set = new TreeSet<>();
        set.add(1);
        set.add(2);
        set.add(3);
        set.add(4);
        set.add(5);
        set.add(6);
        System.out.println(set);
        List<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(4);
        list.add(9);
        set.addAll(list);
        System.out.println(set);
    }
    public static void main5(String[] args) {
        Set<String> set = new TreeSet<>();
        set.add("黑寡妇");
        set.add("绿巨人");
        set.add("鹰眼");
//        set.clear();
//        System.out.println(set.size());
        System.out.println(set);
    }
    public static void main4(String[] args) {
        TreeMap<String,Integer> map = new TreeMap();
        map.put("死侍",19);
        map.put("钢铁侠",20);
        map.put("奇异博士",19);
//        map.put(null,19);
        Set<Map.Entry<String,Integer>> set = map.entrySet();
        Iterator<Map.Entry<String,Integer>> it = set.iterator();
        while(it.hasNext()){
            System.out.println(it.next());
        }
    }
    public static void main3(String[] args) {
        TreeMap<String,Integer> map = new TreeMap();
        map.put("死侍",19);
        map.put("钢铁侠",20);
        map.put("奇异博士",19);
        Set<String> set = map.keySet();
        System.out.println(set);
        Collection<Integer> collection = map.values();
        System.out.println(collection);
    }
    public static void main2(String[] args) {
        TreeMap<Student,Integer> map = new TreeMap();
        map.put(new Student(),10);//因为涉及到对象的比较，Student会被转换为Com类型，但是Student类没有实现该接口
    }
    public static void main1(String[] args) {
        TreeMap<String,Integer> map = new TreeMap();
        map.put("死侍",19);
        map.put("钢铁侠",20);
        map.put("奇异博士",19);
        Integer a = map.get("死恃");
        Integer b = map.getOrDefault("死",100);
        System.out.println(b);
        System.out.println(map);
        map.remove("死侍");
        System.out.println(map);
    }
}
